import time
from selenium import webdriver

# 1. Создать файл locators.py
# 2. 2. Записать 30 уникальных xpath-локаторов, для элементов на странице https://hyperskill.org/tracks

driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://hyperskill.org/tracks")
time.sleep(5)

# Header
explore_button = ("xpath", "//a[contains(text(),'Explore')]")
pricing_button = ("xpath", "//header//a[contains(text(),'Pricing')]")
for_business_button = ("xpath", "//header//a[contains(text(),'For Business')]")

# # Main
h1 = ("xpath", "//h1")
h2 = ("xpath", "//section[@class='scroll-anchor']//h2")

# # Track Categories
link_all_tracks = ("xpath", "//a[contains(@click-event-context, 'all_tracks')]")
link_top_tracks = ("xpath", "//a[contains(@click-event-context, 'top_tracks')]")
link_beginner_friendly = ("xpath", "//a[contains(@click-event-context, 'beginner-friendly')]")
link_career_paths = ("xpath", "//a[contains(@click-event-context, 'career_paths')]")
link_python = ("xpath", "//a[contains(@click-event-context, 'python')]")
link_java = ("xpath", "//a[contains(@click-event-context, 'java')]")
link_javascript = ("xpath", "//a[contains(@click-event-context, 'javascript')]")
link_kotlin = ("xpath", "//a[contains(@click-event-context, 'kotlin')]")
link_go = ("xpath", "//a[contains(@click-event-context, 'go')]")
link_android = ("xpath", "//a[contains(@click-event-context, 'android')]")
link_cpp = ("xpath", "//a[contains(@click-event-context, 'c++')]")
link_generative_ai = ("xpath", "//a[contains(@click-event-context, 'generative_ai')]")
link_math = ("xpath", "//a[contains(@click-event-context, 'math')]")
link_frontend = ("xpath", "//a[contains(@click-event-context, 'frontend')]")
link_sql_and_databases = ("xpath", "//a[contains(@click-event-context, 'sql_and_databases')]")
link_data_science = ("xpath", "//a[contains(@click-event-context, 'data_science')]")
link_bioinformatics = ("xpath", "//a[contains(@click-event-context, 'bioinformatics')]")
link_backend = ("xpath", "//a[contains(@click-event-context, 'backend')]")
link_devops = ("xpath", "//a[contains(@click-event-context, 'devops')]")
link_data_analysis = ("xpath", "//a[contains(@click-event-context, 'data_analysis')]")

# Footer
icon_reddit = ("xpath", '//footer//a[@title="Hyperskill on Reddit"]')
icon_facebook = ("xpath", '//footer//a[@title="Hyperskill on Facebook"]')
icon_linkedin = ("xpath", '//footer//a[@title="Hyperskill on Linkedin"]')
icon_discord = ("xpath", '//footer//a[@title="Hyperskill on Discord"]')
icon_instagram = ("xpath", '//footer//a[@title="Hyperskill on Instagram"]')
icon_tiktok = ("xpath", '//footer//a[@title="Hyperskill on TikTok"]')
icon_youtube = ("xpath", '//footer//a[@title="Hyperskill on YouTube"]')


def check_locators():
    locators = [
        explore_button,
        pricing_button,
        for_business_button,
        h1,
        h2,
        link_all_tracks,
        link_top_tracks,
        link_beginner_friendly,
        link_career_paths,
        link_python,
        link_java,
        link_javascript,
        link_kotlin,
        link_go,
        link_android,
        link_cpp,
        link_generative_ai,
        link_math,
        link_frontend,
        link_sql_and_databases,
        link_data_science,
        link_bioinformatics,
        link_backend,
        link_devops,
        link_data_analysis,
        icon_reddit,
        icon_facebook,
        icon_linkedin,
        icon_discord,
        icon_instagram,
        icon_tiktok,
        icon_youtube
    ]

    for locator in locators:
        try:
            driver.find_element(*locator)
        except:
            print(f"Локатор {locator} не найден на странице.")

check_locators()
